﻿using System.ComponentModel;
using System.IO;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CucumberRunner.RunScenarios{
    //Add a category for each build you want to be notified of in TFS e.g. SmokeTestLive and create a matching profile in cucumber.yml to control which 
    //features are run
    [TestClass]
    public class Runner{
        [TestMethod, Category("SmokeTestLive")]
        public void RunWithPassingProfileForSmokeTestLiveBuildReturnsTrue(){
            string testDirectory = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "..", "..", "CucumberTests"));

            CucumberResults cucumberResults = new CucumberService().Run(testDirectory, "run.bat", "passingProfile", "smokeTestLive.txt");

            Assert.IsTrue(cucumberResults.Passed, "Smoke tests failed for live, see smokeTestLive.txt for details.");
        }

        [TestMethod, Category("SmokeTestLive"), ExpectedException(typeof (Win32Exception))]
        public void RunWithPassingProfileForSmokeTestLiveBuildErrorsWithInvalidUser(){
            string testDirectory = Path.GetFullPath(Path.Combine("..", "..", "..", "..", "..", "..", "CucumberTests"));
           
            var user = new User{Domain = "InvalidDomain", Name = "InvalidName", Password = "InvalidPassword"};

            new CucumberService().Run(testDirectory, "run.bat", "passingProfile", "smokeTestLive.txt", user);
        }
    }
}